<?php global $data; ?>
<?php get_header(); ?>

<!-- BEGIN #main-content -->
<div <?php echo sidebar_position('primary-content'); ?>>
		
	<h1 class="page-title">
		<?php //the_category(', '); ?>
            Blog
	</h1>
	
	<?php if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs(); ?>
		
	<!-- BEGIN .page-content -->
	<div <?php post_class("page-content"); ?>>

		<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
		
		<?php if( has_post_thumbnail() ) { ?>
			<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>">
				<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'image-style1' ); ?>
				<?php echo '<img src="' . $src[0] . '" alt="" class="article-image-full" />'; ?>
			</a>
		<?php } else { ?>
			
			<div class="no-image"></div>
			
		<?php }?>
                        
                <?php   $parentscategory = "";
                        $otherparentscategory = "";
                        foreach((get_the_category()) as $category) {
                            if ($category->category_parent != 0) {
                                $parentscategory .= $category->name . ', ';
                            }else {
                                $otherparentscategory .= $category->name . ', ';
                            }
                        }
                        if ( strlen($parentscategory)== 0) {
                            $parentscategory = $otherparentscategory;
                        }
                ?>
		
		<h2 class="article-title">
			<?php the_title(); ?>
			<span class="article-meta">
				<span class="article-date"><?php the_time('j F, Y'); ?></span><span class="article-category"><?php echo substr($parentscategory,0,-2); ?></span><span class="article-comments"><?php comments_popup_link( 
					__( '0 Comments', 'qns' ), 
					__( '1 Comment', 'qns' ), 
					__( '% Comment', 'qns' ), 
					'',
					__( '<span class="comments-off">Off</span>','qns')
				); ?></span>
			</span>
		</h2>
		
		<?php the_content(); ?>
		
		<p class="post-tags"><?php the_tags( __('Tags: ','qns'), ', ', '' ); ?></p>

		<?php 
			wp_link_pages( array( 
				'before' => '<div class="page-pagination">', 
				'after' => '</div>', 
				'link_before' => '<span class="page">', 
				'link_after' => '</span>'
			) ); 
		?>
		
		<?php if( $data['display_sharing_options'] ) { ?>
		
			<div class="article-social-links">		
				<ul class="clearfix">
					<li class="tweet-link"><a target="_blank" href="http://twitter.com/share?text=<?php the_title(); ?>"><?php _e('Tweet this article','qns'); ?></a></li>
					<li class="facebook-link"><a target="_blank" href="http://www.facebook.com/sharer.php?u=<?php the_permalink(); ?>/&t=<?php the_title(); ?>"><?php _e('Share on Facebook','qns'); ?></a></li>
					<li class="pinterest-link"><a target="_blank" href="http://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>&media=<?php echo $src[0]; ?>&description=<?php the_title();?>"><?php _e('Pin on Pinterest','qns'); ?></a></li>
				</ul>
			</div>
		
		<?php } ?>
		
		<?php if( $data['display_recommended_articles'] ) { ?>
		
			<?php $categories = get_the_category(); ?>
			<?php query_posts( "post_type=post&posts_per_page=5&cat=" . $categories[0]->cat_ID ); ?>
			<?php if ( have_posts() ) : ?>
			
				<div class="title-block">
					<h3><?php _e('Recommended','qns'); ?></h3>
				</div>
			
				<ul class="news-block-columns-5 clearfix" style="margin: 0 !important;">
					<?php while ( have_posts() ) : the_post(); ?>
						<?php get_template_part( 'loop', 'style4' ); ?>
					<?php endwhile;wp_reset_query(); ?>
				</ul>
			<?php endif; ?>
		
		<?php } ?>
		
		<?php endwhile; endif; ?>

		<?php if ( comments_open() ) : ?>
			<div class="fb-comments" data-href="<?php the_permalink(); ?>" data-width="658px" data-numposts="5" data-colorscheme="light"></div>
		<?php endif; ?>
		
	<!-- END .page-content -->
	</div>
		
<!-- BEGIN #main-content -->
</div>

<div id="sidebar-content"  class="sidebar-content-left-sidebar">
    <?php 
        dynamic_sidebar( 'Blog Sidebar' ); 
    ?>
    <div class="sidebar-fade"></div>
</div>

<?php get_footer(); ?>